import { DatePicker } from 'antd';
import type { RangePickerProps, DatePickerProps } from 'antd/lib/date-picker';
import type { FC } from 'react';
import styles from './index.less';
interface Props {
  prefixText: string;
  isRange?: boolean;
  showTime?: boolean;
}
const Index: FC<Props & (RangePickerProps | DatePickerProps)> = ({
  prefixText,
  isRange = true,
  showTime = false,
  placeholder = ['请选择', '请选择'],
  style,
  ...props
}) => {
  return (
    <div className={styles.container}>
      <span>{prefixText}</span>
      {isRange ? (
        <DatePicker.RangePicker
          placeholder={placeholder}
          showTime={showTime}
          style={{ ...style, flex: 1, height: 44 }}
          {...props}
        />
      ) : (
        <DatePicker
          placeholder={placeholder}
          style={{ ...style, flex: 1, height: 44 }}
          {...props}
        />
      )}
    </div>
  );
};
export default Index;
